package com.mdb;

import org.apache.log4j.Logger;

import javax.annotation.Resource;
import javax.ejb.MessageDriven;
import javax.ejb.MessageDrivenContext;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;


//@MessageDriven(mappedName="java:app/jms/dest")
@MessageDriven(mappedName="jms/myDestination")
public class MessageConsumer implements MessageListener {

    public static final Logger LOG = Logger.getLogger(MessageConsumer.class);

    @Resource
    private MessageDrivenContext mdc;

    @Override
    public void onMessage(Message message)
    {
        TextMessage textMessage = (TextMessage) message;
        try
        {
            LOG.info("MDB TextMessage: " + textMessage.getText());
        } catch (JMSException ex)
        {
            LOG.error("JMSException: " + ex);
        }
    }
}
